package my.jieh.tips.swing.window;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * <p>Title: Core Java Technologies Tech Tips</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2002</p>
 *
 * <p>Company: Blueimp</p>
 *
 * @author jieh
 * @version 1.0
 */
public class WarnMe {
  public static void main(final String args[]) {
    Runnable runner = new Runnable() {
      public void run() {
        JDialog.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame("Show Warning");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton button = new JButton("Warn Me");
        ActionListener listener = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object[] options = { "Run", "Walk", "Hide" };
            JOptionPane.showOptionDialog(
              null, "Red Alert", "Warning",
              JOptionPane.DEFAULT_OPTION,
              JOptionPane.WARNING_MESSAGE,
              null, options, options[0]);
          }
        };
        button.addActionListener(listener);
        frame.add(button);
        frame.setSize(300, 100);
        frame.setVisible(true);
      }
    };
    EventQueue.invokeLater(runner);
  }
}
